importPackage(net.sf.odinms.client);

var status = 0;
var char = null;

function start() {
	status = -1;
	action(1, 0, 0);
}

function start(MapleCharacter cha) {
	char = cha;
	status = -1;
	action(1, 0, 0);
}

function action(mode, type, selection, char) {
	if (mode == -1) {
		cm.dispose();
	} else {
		if (mode == 0) {
			if (char != null)
				char.dropMessage(cm.getChar().getName() + " does not want to marry you. Sorry");
			else
				cm.sendOk("Goodbye.");
			cm.dispose();
			return;
		}
		if (mode == 1) status++;
		else status--;
		if (status == 0) {
			if (char == null)
				cm.sendOk("Hello, do you want to marry someone?");
			else
				cm.sendAcceptDecline(char.getName() + " wants to marry you\r\nDo you accept this proposal?\r\nIf you do I will warp you here.");
		} else {
			if (char != null)
				cm.warp(char.getMapId(), char.getInitialSpawnpoint());
			cm.dispose();
		}
	}
}